﻿using System;
using System.Collections.ObjectModel;
using Microsoft.Phone.Reactive;
using SoTools.Communicator.TestMessage;

namespace SoTools.Communicator.TestWp7
{
	public partial class MainPage
	{
		public ObservableCollection<Message> Messages { get; private set; }

		public MainPage()
		{
			Messages = new ObservableCollection<Message>();
			DataContext = this;
			
			var communicator = new Communicator();
			communicator.Listen();
			communicator.GenerateObservable<Message>().Subscribe(m => Dispatcher.BeginInvoke(() => Messages.Add(m)));

			InitializeComponent();
		}
	}
}